/*
 * *
 *  * Created with IntelliJ RustRover.
 *  * Description:
 *  * Copyright Author: ZhenYi
 *  * DateTime: 2024/2/14 下午5:10
 *
 */


use serde::{Deserialize, Serialize};
use crate::config::info::auth::Auth;


#[derive(Deserialize,Serialize,Clone)]
pub struct Pgsql{
    ip:String,
    port:String,
    db:String,
    auth:Auth,
}

impl Default for Pgsql{
    fn default() -> Self {
        Self{
            ip:String::new(),
            port:String::new(),
            db:String::new(),
            auth:Auth::default()
        }
    }
}

impl Pgsql {
    pub fn format(&self) ->String{
        format!("postgres://{}:{}@{}:{}/{}",
        self.auth.username(),
        self.auth.password(),
        self.ip,
        self.port,
        self.db)
    }
}